//
//  SignOutNoticView.m
//  RichPay
//
//  Created by apple on 2017/12/7.
//  Copyright © 2017年 rich001. All rights reserved.
//

#import "SignOutNoticView.h"

@interface SignOutNoticView ()

@end

@implementation SignOutNoticView

- (void)viewDidLoad {
    [super viewDidLoad];

    UIView * bgView = [UIView new];
    [self.view addSubview:bgView];
    _bgView = bgView;
    CGFloat bgViewH;
    if (iPhoneX)
    {
        bgViewH = 220 * (SCREEN_WIDTH / 375);
    }else
    {
        bgViewH = 200 * (SCREEN_HEIGHT / 667);
    }
    
    bgView.backgroundColor = kWhiteColor;
//    bgView.frame = CGRectMake(SCREEN_WIDTH/2, SCREEN_HEIGHT/2, 300 * (SCREEN_WIDTH / 375), 200 * (SCREEN_HEIGHT / 667));
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view.mas_centerX);
        make.centerY.mas_equalTo(self.view.mas_centerY);
        make.width.mas_equalTo(300 * (SCREEN_WIDTH / 375));
        make.height.mas_equalTo(bgViewH);
    }];
//    alertControllerWithTitle:CLocalizedString(@"SIGN OUT") message:CLocalizedString(@"Determine the logout account?")
    UILabel * titleLabel = [bgView addLabelWithFrame:CGRectZero title:Localized(@"Sign Out")];
    _titleLabel = titleLabel;
    titleLabel.textColor = kBlackColor;
    titleLabel.font = Kfont(18);
    titleLabel.textAlignment = NSTextAlignmentCenter;
//    titleLabel.frame = CGRectMake(kSpacingDistance, CGRectGetMaxY(bgView.frame) + kSpacingDistance, 300 * (SCREEN_WIDTH / 375) - kDistance20, FoneSizeNum(20));
    CGFloat titleTop;
    if (iPhoneX)
    {
        titleTop = 20 * (SCREEN_WIDTH / 375);
    }else
    {
        titleTop = 20 * (SCREEN_HEIGHT / 667);
    }
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(bgView.mas_centerX);
        make.top.mas_equalTo(titleTop);
        make.width.mas_equalTo(150);
    }];
    
    CGFloat buttonH;
    if (iPhoneX)
    {
        buttonH = 50* (SCREEN_WIDTH / 375);
    }else
    {
        buttonH = 50* (SCREEN_HEIGHT / 667);
    }
    UIButton *cancelBtn = [[UIButton alloc] init];
    _cancelBtn = cancelBtn;
    [cancelBtn setBackgroundImage:[PublicUtil createImageWithColor:kGrayColor] forState:UIControlStateNormal];
    [cancelBtn setTitle:Localized(@"Cancel") forState:UIControlStateNormal];
    [cancelBtn setTitleColor:kBlackColor forState:UIControlStateNormal];
    [cancelBtn addTarget:self action:@selector(cancelBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [bgView addSubview:cancelBtn];
    [cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.bottom.mas_equalTo(-10);
        make.width.mas_equalTo((300 * (SCREEN_WIDTH / 375) - 20) / 2);
        make.height.mas_equalTo(buttonH);
    }];
    
    UIButton *confirmBtn = [[UIButton alloc] init];
    confirmBtn.backgroundColor = kwarningColor;
    _confirmBtn = confirmBtn;
    [confirmBtn setTitle:Localized(@"Confirm1") forState:UIControlStateNormal];
    [confirmBtn setTitleColor:kWhiteColor forState:UIControlStateNormal];
    [confirmBtn setTitleColor:kLightBlackColor forState:UIControlStateHighlighted];
    [confirmBtn setBackgroundImage:[UIImage imageNamed:@"buttoncanclick_icon"] forState:UIControlStateNormal];
    [confirmBtn addTarget:self action:@selector(confirmBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [bgView addSubview:confirmBtn];
    [confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.bottom.mas_equalTo(-10);
        make.width.mas_equalTo((300 * (SCREEN_WIDTH / 375) - 20) / 2);
        make.height.mas_equalTo(buttonH);
    }];
    
    UILabel * contenLabel = [bgView addLabelWithFrame:CGRectZero title:Localized(@"Proceed to logout?")];
    _contenLabel = contenLabel;
    contenLabel.textColor = titleLabel.textColor;
    contenLabel.font = Kfont(16);
    contenLabel.numberOfLines = 0;
    contenLabel.textAlignment = NSTextAlignmentCenter;
    //    contenLabel.frame = CGRectMake(kSpacingDistance, CGRectGetMaxY(titleLabel.frame) + kSpacingDistance, 300 * (SCREEN_WIDTH / 375) - kDistance20, 100);
    CGFloat contentTop;
    if (iPhoneX)
    {
        contentTop = 10+20 * (SCREEN_WIDTH / 375);
    }else
    {
        contentTop = 10+20 * (SCREEN_HEIGHT / 667);
    }
    [contenLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(titleLabel.mas_bottom).offset(0);
        make.bottom.mas_equalTo(confirmBtn.mas_top);
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
    }];
}

- (void)cancelBtnClick:(UIButton *)btn {
    self.SignOutNoticViewHideClickBlock(1);
}

- (void)confirmBtnClick:(UIButton *)btn {
    self.SignOutNoticViewHideClickBlock(0);
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    self.SignOutNoticViewHideClickBlock(2);
}

@end
